From a155403e2aafd4c65689752e811023d1fb7098b6 Mon Sep 17 00:00:00 2001 From: robertl Date: Thu, 17 Apr 2003 03:53:21 +0000 Subject: [PATCH] Free handles when done. Copy from and free jeeps structures when reading from Garmin. --- gpsbabel/garmin.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gpsbabel/garmin.c b/gpsbabel/garmin.c index 1478d3ef5..ce5c824b1 100644 --- a/gpsbabel/garmin.c +++ b/gpsbabel/garmin.c @@ -53,6 +53,10 @@ rw_init(const char *fname, const char *opts) static void rw_deinit(void) { + if (mkshort_handle) { + mkshort_del_handle(mkshort_handle); + mkshort_handle = NULL; + } } static void @@ -68,8 +72,8 @@ waypt_read(void) for (i = 0; i < n; i++) { waypoint *wpt_tmp = xcalloc(sizeof(*wpt_tmp),1); - wpt_tmp->shortname = way[i]->ident; - wpt_tmp->description = way[i]->cmnt; + wpt_tmp->shortname = xstrdup(way[i]->ident); + wpt_tmp->description = xstrdup(way[i]->cmnt); wpt_tmp->position.longitude.degrees = way[i]->lon; wpt_tmp->position.latitude.degrees = way[i]->lat; /* @@ -91,6 +95,7 @@ waypt_read(void) } waypt_add(wpt_tmp); + GPS_Way_Del(&way[i]); } } @@ -245,6 +250,9 @@ data_write(void) mkshort(mkshort_handle, src) : wpt->shortname; strncpy(way[i]->ident, ident, sizeof(way[i]->ident)); + if (global_opts.synthesize_shortnames) { + xfree(ident); + } way[i]->ident[sizeof(way[i]->ident)-1] = 0; if (src && strlen(src)) { strncpy(way[i]->cmnt, src, sizeof(way[i]->cmnt)); -- 2.30.2